/*
 * @Author: 徐建辰
 * @Date: 2022-04-15 14:21:13
 * @LastEditTime: 2022-06-23 08:58:40
 * @LastEditors: xjc
 * @Description: 入口主文件，类似于main.js
 */
import config from '@/config'
import errorHandler from '@/utils/errorHandler'

import * as myIcons from '@/plugins/svg-icon'
import * as elIcons from '@element-plus/icons-vue'
// import * as elIcons from '@element-plus/icons'

import Dialog from '@/components/Dialog'
import Button from '@/components/Button'
import SvgIcon from '@/components/SvgIcon'
import ComEmpty from '@/components/Empty'
import ComWrapper from '@/components/Wrapper'

import auth from '@/directives/auth'
import copy from '@/directives/copy'

export default {
  install(app) {
    app.config.globalProperties.$CONFIG = config
    app.config.errorHandler = errorHandler

    app.component('Dialog', Dialog)
    app.component('Button', Button)
    app.component('SvgIcon', SvgIcon)
    app.component('ComEmpty', ComEmpty)
    app.component('ComWrapper', ComWrapper)
    
    //注册全局指令
		app.directive('auth', auth)
		app.directive('copy', copy)

    // 统一注册el-icon图标和自定义svg
		for (let icon in elIcons) {
			app.component(`ElIcon${icon}`, elIcons[icon])
		}
    for (let icon in myIcons) {
			app.component(`MyIcon${icon}`, myIcons[icon])
		}
  }
}